home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Plus 2000 #4
/
Amiga Plus CD - 2000 - No. 4.iso
/
Vollversion
/
CamD
/
development
/
examples
/
drum
/
asymbevel.a
< prev
next >
Wrap
Text File
|
2000-05-15
|
12KB
|
283 lines
* ============================================================================ *
* ASymBevel: Draws an asymmetrical (thicker on one side).
*
* AsymBevel(rp, ibox, ulpen, lrpen, fillpen, side);
* a0 a1 d0 d1 d2 d3
*
* ============================================================================ *
*
* void _asm AsymBevel( register __a0 struct RastPort *rp,
* register __a1 struct IBox *b,
* register __d0 LONG ulpen,
* register __d1 LONG lrpen,
* register __d2 LONG fillpen,
* register __d3 WORD side );
*
* ============================================================================ *
*
* Here's a rough picture of what the asymmetrical bevels look like.
* Essentially, the bevels seperating the two buttons are only a single
* pixel wide, whereas the bevels on either side of the buttons are two
* pixels wide.
*
* My reason for doing this is that I think it looks nicer.
*
* %%%%%%%%%%%%%%%%%%%%%%%%%%
* %%%%%%%%%%%%%%%%%%%%%%%%%%
* %%%% M%%%%
* %%%% %%%%%%M %%%%%%MM%%%%
* %%%% %%%MM%M %MM%%%MM%%%%
* %%%% %%MM%%M %%MM%%MM%%%%
* %%%% %MM%%%M %%%MM%MM%%%%
* %%%% %%MM%%M %%MM%%MM%%%%
* %%%% %%%MM%M %MM%%%MM%%%%
* %%%% %%%%%%M %%%%%%MM%%%%
* %%%% MMMMMMMMMMMMMMMMM%%%%
* %%%%%%%%%%%%%%%%%%%%%%%%%%
* %%%%%%%%%%%%%%%%%%%%%%%%%%
*
* ============================================================================ *
include "exec/types.i"
include "intuition/intuition.i"
; include "macros.i"
SECTION asymbevel.asm,CODE
; far code
; far data
xdef _AsymBevel
xref _LVOSetAPen,_LVORectFill,_GfxBase
qregs reg d2-d7/a2/a6
* AsymBevel(rp, ibox, ulpen, lrpen, fillpen, side);
* a0 a1 d0 d1 d2 d3
*
LEFT equr d4
TOP equr d5
RIGHT equr d6
BOTTOM equr d7
_AsymBevel:
movem.l qregs,-(sp)
; move.l d1,d2 ; d2 <-- lrpen
move.l a0,a2 ; save RastPort pointer
move.l _GfxBase,a6 ; a6 register
;---------- set up box
moveq #0,LEFT ; clear upper half of regs
moveq #0,TOP
moveq #0,RIGHT
moveq #0,BOTTOM
movem.w (a1),LEFT/TOP/RIGHT/BOTTOM
; d4 <-- ibox_Left
; d5 <-- ibox_Top
; d6 <-- ibox_Width
; d7 <-- ibox_Height
add.w LEFT,RIGHT ; d6 <-- right
add.w TOP,BOTTOM ; d7 <-- bottom
subq.w #1,RIGHT ; d6 <-- right - 1
subq.w #1,BOTTOM ; d7 <-- bottom - 1
;---------- left side
tst.w d3
bne 50$ ; do right side
move.l d2,-(sp) ; save fillpen
move.l d1,-(sp) ; save lrpen
; move.l d0,d0 ; d0 already has ulpen
move.l a2,a1 ; a1 <-- rastport
jsr _LVOSetAPen(a6) ; set pen
move.l LEFT,d0 ; d0 <-- left
move.l TOP,d1 ; d1 <-- top
move.l RIGHT,d2 ; d2 <-- right
move.l TOP,d3 ; d3 <-- top
move.l a2,a1 ; a1 <-- rastport
jsr _LVORectFill(a6) ; rectangle fill
move.l LEFT,d0 ; d0 <-- left
move.l TOP,d1 ; d1 <-- top
move.l LEFT,d2
addq.l #1,d2 ; d2 <-- left + 1
move.l BOTTOM,d3 ; d3 <-- bottom
move.l a2,a1 ; a1 <-- rastport
jsr _LVORectFill(a6) ; rectangle fill
move.l (sp)+,d0 ; d0 <-- lrpen
move.l a2,a1 ; a1 <-- rastport
jsr _LVOSetAPen(a6) ; set pen
move.l RIGHT,d0 ; d0 <-- right
move.l TOP,d1
addq.l #1,d1 ; d2 <-- top + 1
move.l RIGHT,d2 ; d2 <-- right
move.l BOTTOM,d3 ; d3 <-- bottom
move.l a2,a1 ; a1 <-- rastport
jsr _LVORectFill(a6) ; rectangle fill
move.l LEFT,d0
addq.l #1,d0 ; d0 <-- left + 1
move.l BOTTOM,d1 ; d1 <-- bottom
move.l RIGHT,d2 ; d2 <-- right
move.l BOTTOM,d3 ; d3 <-- bottom
move.l a2,a1 ; a1 <-- rastport
jsr _LVORectFill(a6) ; rectangle fill
move.l (sp)+,d0 ; fillpen
bmi 99$ ; if no fillpen, then leave
move.l a2,a1 ; a1 <-- rastport
jsr _LVOSetAPen(a6) ; set pen
move.l LEFT,d0
addq.l #2,d0 ; d0 <-- left + 2
move.l TOP,d1
addq.l #1,d1 ; d1 <-- top + 1
move.l RIGHT,d2
subq.l #1,d2 ; d1 <-- right - 1
move.l BOTTOM,d3
subq.l #1,d3 ; d1 <-- bottom - 1
cmp.w d2,d0 ; if left >= right
bge 99$ ; then quit
cmp.w d2,d0 ; if top >= bottom
bge 99$ ; then quit
move.l a2,a1 ; a1 <-- rastport
jsr _LVORectFill(a6) ; rectangle fill
bra 99$
50$ move.l d2,-(sp) ; save fillpen
move.l d0,-(sp) ; save ulpen
move.l d1,d0 ; d0 <-- lrpen
move.l a2,a1 ; a1 <-- rastport
jsr _LVOSetAPen(a6) ; set pen
move.l RIGHT,d0
subq.l #1,d0 ; d0 <-- right
move.l TOP,d1 ; d1 <-- top
move.l RIGHT,d2 ; d2 <-- right
move.l BOTTOM,d3 ; d3 <-- bottom
move.l a2,a1 ; a1 <-- rastport
jsr _LVORectFill(a6) ; rectangle fill
move.l LEFT,d0 ; d0 <-- left
move.l BOTTOM,d1 ; d1 <-- bottom
move.l RIGHT,d2 ; d2 <-- right
move.l BOTTOM,d3 ; d3 <-- bottom
move.l a2,a1 ; a1 <-- rastport
jsr _LVORectFill(a6) ; rectangle fill
move.l (sp)+,d0 ; d0 <-- lrpen
move.l a2,a1 ; a1 <-- rastport
jsr _LVOSetAPen(a6) ; set pen
move.l LEFT,d0 ; d0 <-- left
move.l TOP,d1 ; d1 <-- top
move.l RIGHT,d2
subq.l #1,d2 ; d2 <-- right + 1
move.l TOP,d3 ; d3 <-- top
move.l a2,a1 ; a1 <-- rastport
jsr _LVORectFill(a6) ; rectangle fill
move.l LEFT,d0 ; d0 <-- left
move.l TOP,d1 ; d1 <-- top
move.l LEFT,d2 ; d2 <-- left
move.l BOTTOM,d3
subq.l #1,d3 ; d2 <-- bottom - 1
move.l a2,a1 ; a1 <-- rastport
jsr _LVORectFill(a6) ; rectangle fill
move.l (sp)+,d0 ; fillpen
bmi 99$ ; if no fillpen, then leave
move.l a2,a1 ; a1 <-- rastport
jsr _LVOSetAPen(a6) ; set pen
move.l LEFT,d0
addq.l #1,d0 ; d0 <-- left + 1
move.l TOP,d1
addq.l #1,d1 ; d1 <-- top + 1
move.l RIGHT,d2
subq.l #2,d2 ; d1 <-- right - 2
move.l BOTTOM,d3
subq.l #1,d3 ; d1 <-- bottom - 11
cmp.w d2,d0 ; if left >= right
bge.s 99$ ; then quit
cmp.w d2,d0 ; if top >= bottom
bge.s 99$ ; then quit
move.l a2,a1 ; a1 <-- rastport
jsr _LVORectFill(a6) ; rectangle fill
99$ movem.l (sp)+,qregs
rts
end
/* original C code */
void AsymBevel(
struct RastPort *rp, /* rast port to use */
struct IBox *b, /* extent of bevel */
LONG ulpen, /* upper-left pen */
LONG lrpen, /* lower-right pen */
LONG fillpen, /* pen to fill with, or -1=none */
WORD side ) /* 0 = left side, 1 = right side*/
{ UWORD left = b->Left,
right = left + b->Width - 1,
top = b->Top,
bottom = top + b->Height - 1;
/* left side thicker */
#if 0
.........
.. x
.. x
.xxxxxxxx
........x
. xx
. xx
xxxxxxxxx
#endif
if (side == 0)
{ SetAPen( rp, ulpen );
RectFill( rp, left, top, right, top );
RectFill( rp, left, top, left+1, bottom );
SetAPen( rp, lrpen );
RectFill( rp, right, top+1, right, bottom );
RectFill( rp, left+1, bottom, right, bottom );
if (fillpen >= 0 && left + 3 < right && top + 2 < bottom)
{ SetAPen( rp, fillpen );
RectFill( rp, left + 2, top + 1, right - 1, bottom - 1 );
}
}
else
{ SetAPen( rp, lrpen );
RectFill( rp, right - 1, top, right, bottom );
RectFill( rp, left, bottom, right, bottom );
SetAPen( rp, ulpen );
RectFill( rp, left, top, right - 1, top );
RectFill( rp, left, top, left, bottom - 1 );
if (fillpen >= 0 && left + 3 < right && top + 2 < bottom)
{ SetAPen( rp, fillpen );
RectFill( rp, left + 1, top + 1, right - 2, bottom - 2 );
}
}
}